package com.example.mycharttest;

import java.util.ArrayList;
import java.util.List;


import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.app.Activity;

public class HomeActivity extends Activity {

	LinearLayout arc;
    RelativeLayout pillars,linear;
    
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.home);

		arc = (LinearLayout) findViewById(R.id.arc);
		arc.addView(new HomeArc(this, 90)); 
		
		List<Score> list = new ArrayList<Score>();;//新建一个list数组，往里面添加10~100之间的数
		for (int i = 0; i < 28; i++) {
			Score s = new Score();//自定义Score类，用于在Activity之间传递数据
			s.date = "2013-10-" + i;
			s.score = getRandom(10,100);
			list.add(s);
		}
		pillars= (RelativeLayout) findViewById(R.id.pillars);
		pillars.addView(new HomeColumnar(this,list));
		
		List<Integer> lists = new ArrayList<Integer>();//新建一个lists数组，并往lists数组里添加0~500之间的随机数
		for (int i = 0; i < 48; i++) {
			if (i < 8 || i == 28 || i == 12 || i == 18 || i == 20 || i == 30
					|| i == 34) {
				lists.add(0);
			} else {
				lists.add(getRandom(0, 500));
			}
		}
		linear= (RelativeLayout) findViewById(R.id.linear);
		//实例化HomeDiagram类，并将该类显示在linear布局中。
		//将lists数组作为参数传到HomeDiagram.java中去
		//在实例化中，使用this关键字作为参数？   把当前对象Activity2作为参数传递给HomeDiagram对象的构造函数
		linear.addView(new HomeDiagram(this,lists));
		
	}
	
	public int getRandom(int min,int max){
		return (int) Math.round(Math.random()*(max-min)+min);
	}

}
